package com.eliza.base.views.component.slider

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Slider
import androidx.compose.material3.SliderDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController

@Composable
fun SliderScreen(navController: NavController) {
    Column {
        SliderMinimalExample()

    }
}

@Preview
@Composable
private fun SliderMinimalExample() {
    Column {
        sliderSimple(true, 0)
        sliderSimple(true, 4)
        sliderSimple(false, 1)
    }
}

@Composable
private fun sliderSimple(enabled: Boolean, steps: Int) {
    var sliderPosition by remember { mutableFloatStateOf(0f) }
    Slider(
        value = sliderPosition,
        onValueChange = { sliderPosition = it },
        modifier = Modifier.padding(1.dp),
        enabled = enabled,
        valueRange = 0f..1f,
//        /*@IntRange(from = 0)*/
        steps = steps, //steps-如果大于0，则指定离散允许值的数量，均匀分布在整个值范围内。如果为0，滑块将连续运行，并允许指定范围内的任何值。不得为负数。
        onValueChangeFinished = {},
        colors = SliderDefaults.colors(),
        interactionSource = remember { MutableInteractionSource() }
    )
    Text(text = sliderPosition.toString())
}